<?php
class User extends AppModel {
 
    var $name = 'User';
    var $belongsTo = array('Group','Secretquestion','City','State','Country');
   var $actsAs = array('Acl' => array('type' => 'requester'));


	var $validate = array(
		'username' => array(
			'notempty' => array(
				'rule' => array('notempty'),
				'message' => 'This field cann\'t Empty!',
			),
		),
		'password' => array(
			'notempty' => array(
				'rule' => array('notempty'),
				'message' => 'This field cann\'t Empty!',
			),
		),
		
		'first_name' => array(
			'notempty' => array(
				'rule' => array('notempty'),
				'message' => 'This field cann\'t Empty!',
			),
		),
		'last_name' => array(
			'notempty' => array(
				'rule' => array('notempty'),
				'message' => 'This field cann\'t Empty!',

			),
		),
		'street' => array(
			'notempty' => array(
				'rule' => array('notempty'),
				'message' => 'This field cann\'t Empty!',
			),
		),
		'address' => array(
			'notempty' => array(
				'rule' => array('notempty'),
				'message' => 'This field cann\'t Empty!',
			),
		),
		'city' => array(
			'notempty' => array(
				'rule' => array('notempty'),
				'message' => 'This field cann\'t Empty!',
			),
		),
		'state' => array(
			'notempty' => array(
				'rule' => array('notempty'),
				'message' => 'This field cann\'t Empty!',
			),
		),
		'zip' => array(
			'notempty' => array(
				'rule' => array('notempty'),
				'message' => 'This field cann\'t Empty!',
			),
		),
		'country' => array(
			'notempty' => array(
				'rule' => array('notempty'),
				'message' => 'This field cann\'t Empty!',
			),
		),
		
		'email' => array(
			'email' => array(
				'rule' => array('email'),
				'message' => 'Please Enter a Valid Email Address.',
			),
			'notempty' => array(
				'rule' => array('notempty'),
				'message' => 'This field cann\'t Empty!',
			),
		),
		'secretquestion_id' => array(
			'numeric' => array(
				'rule' => array('numeric'),
				'message' => 'This field cann\'t Empty!',
			),
		),
		'ques_ans' => array(
			'notempty' => array(
				'rule' => array('notempty'),
				'message' => 'This field cann\'t Empty!',
			),
		),
	);

        var $hasMany = array(
		'BrandPermission' => array(
			'className' => 'BrandPermission',
			'foreignKey' => 'user_id',
			'dependent' => false,
			'conditions' => '',
			'fields' => '',
			'order' => '',
			'limit' => '',
			'offset' => '',
			'exclusive' => '',
			'finderQuery' => '',
			'counterQuery' => ''
		),
            'MessageTrackSent' => array(
            'className' => 'MessageTrack',
            'foreignKey' => 'from_id'
        ),
        'MessageTrackReceived' => array(
            'className' => 'MessageTrack',
            'foreignKey' => 'to_id'
        ),
        'Product' => array(
            'className' => 'Product',
            'foreignKey' => 'user_id'
        )

	);
    function parentNode(){
        if (!$this->id) {
            return null;
        }
        $data = $this->read();
        if (!$data['User']['group_id']){
            return null;
        } else {
            return array('model' => 'Group', 'foreign_key' => $data['User']['group_id']);
        }
    }

}
?>